<template>
	<view class="container">
		<u-modal :show="show" title="退出登录" :content='content' showCancelButton="true" @cancel="show=false"
			@confirm="handleOutConfirm"></u-modal>

		<view class="top-bg">
			<!-- 头像和昵称盒子 -->
			<view class="avatar_name">
				<!-- 头像盒子 -->
				<view class="avatar">
					<view class="icon_man" v-if="tuser.gender=='男'">
						<u-icon name="man" color="#fff" size="16"></u-icon>
					</view>
					<view class="icon_woman" v-if="tuser.gender=='女'">
						<u-icon name="woman" color="#fff" size="16"></u-icon>
					</view>

					<u-avatar shape="square" :src="user.avatar" size="60"></u-avatar>
				</view>
				<view class="all_nick">
					<view class="nick_tag">
						<!-- 昵称 -->
						<view class="nickName">{{user.nickName}}

						</view>
						<view class="tag">
							<u-tag v-if="user.roleId==1" text="老师" size="mini" type="warning"></u-tag>
							<u-tag v-if="user.roleId==2" text="学生" size="mini" type="success"></u-tag>
						</view>
					</view>
					<!-- id盒子 -->
					<view class="user-id">
						ID：{{user.userId}}
					</view>
				</view>


			</view>

			<!-- 白色弧度 -->
			<!-- <view class="withe-box"></view> -->
		</view>
		<view class="content">
			<view class="center">
				<u-cell-group>
					<!-- 				<u-cell icon="setting-fill" title="账号设置">
					</u-cell> -->
					<u-cell icon="setting-fill" size="large" url="/subpages/my_res_today/my_res_today" title="今日预约"
						isLink>
						<u-icon slot="icon" size="28" name="calendar" color="red"></u-icon>
					</u-cell>
					<u-cell size="large" title="我的预约" url="/subpages/my_res/my_res" isLink>
						<u-icon slot="icon" size="25" name="clock" color="#00b2bd"></u-icon>
					</u-cell>
					<u-cell size="large" title="我的收藏" url="/subpages/my_collect/my_collect" isLink>
						<u-icon slot="icon" size="28" name="star" color="#f4ea2a"></u-icon>
					</u-cell>

				</u-cell-group>

			</view>
			<view class="bottom">
				<u-cell-group>

					<u-cell size="large" title="修改密码" url="/subpages/update_password/update_password" isLink>
						<u-icon slot="icon" size="28" name="edit-pen" color="#3793df"></u-icon>
					</u-cell>
					<u-cell size="large" title="账号信息" url="/subpages/update_user_Info/update_user_Info" isLink>
						<u-icon slot="icon" size="28" name="account" color="#5064eb"></u-icon>
					</u-cell>
					<u-cell size="large" title="关于作者" url="/pages/about_author/about_author" isLink>
						<u-icon slot="icon" size="26" name="more-circle" color="#ffcc2c"></u-icon>
					</u-cell>

				</u-cell-group>
			</view>

		</view>
		<view class="logout">
			<u-button type="primary" text="退出登录" @click="handleLogOut"></u-button>
		</view>

	</view>
</template>

<script>
	import {
		removeToken
	} from '../../utils/auth.js'
	import Umodal from '../../uni_modules/uview-ui/components/u-modal/u-modal.vue'
	export default {
		data() {
			return {
				// 退出登录的信息提示
				content: "是否确认退出登录",
				// 是否显示对话框
				show: false,
				user: {},
				tuser: {}
			};
		},
		components: {
			Umodal
		},
		onShow() {
			let user = uni.getStorageSync('user')
			let tuser = uni.getStorageSync('tuser')
			this.user = user
			this.tuser = tuser
		},
		methods: {
			// 确认退出登录
			handleOutConfirm() {
				// 清除本地缓存数据
				uni.clearStorageSync()
				// 跳转到登录页
				uni.reLaunch({
					url: "/pages/front-login/front-login"
				})
				//同时关闭对话框
				this.show = false
			},
			// 退出登录按钮点击事件
			handleLogOut() {
				this.show = true
			}
		}
	}
</script>

<style lang="scss">
	.container {
		width: 100%;
		min-height: 100vh;
		// background-color: pink;
		position: relative;

		.top-bg {
			position: relative;
			width: 100%;
			height: 222upx;
			background-color: #5064eb;
			display: inline-block;

			.avatar_name {
				position: relative;

				display: flex;
				flex-direction: row;
				justify-content: left;
				align-items: center;
				margin-top: 13upx;


				.avatar {
					position: relative;
					margin-left: 30upx;
					margin-right: 30upx;

					.icon_man {
						position: absolute;
						top: -10upx;
						right: -10upx;
						width: 35upx;
						height: 35upx;
						border-radius: 50%;
						background-color: #0084ff;
						z-index: 999;
						display: flex;
						flex-direction: row;
						justify-content: center;
						align-items: center;

					}

					.icon_woman {
						position: absolute;
						top: -10upx;
						right: -10upx;
						width: 35upx;
						height: 35upx;
						border-radius: 50%;
						background-color: hotpink;
						z-index: 999;
						display: flex;
						flex-direction: row;
						justify-content: center;
						align-items: center;

					}
				}

				.all_nick {


					.nick_tag {
						display: flex;
						flex-direction: row;
						justify-content: flex-start;
						align-items: center;
					}
				}




				.nickName {
					font-size: 16px;
					color: #fff;
					margin-right: 20upx;
				}

				.tag {
					width: 75upx;
				}
			}

			.user-id {
				font-size: 16px;
				color: #fff;
				margin-top: 10upx;
			}

			.withe-box {
				position: absolute;
				bottom: -1upx;
				width: 100%;
				height: 45upx;
				border-top-left-radius: 31upx;
				border-top-right-radius: 31upx;
				background-color: #fff;
			}
		}

		.content {
			position: absolute;
			top: 175upx;
			width: 100%;
			box-sizing: border-box;
			padding: 0 15upx;

			.center {
				width: 100%;
				min-height: 217rpx;
				background-color: #fff;
				box-shadow: 0rpx 0rpx 11rpx rgba(0, 0, 0, 0.15);
				border-radius: 15rpx;
			}

			.bottom {
				width: 100%;
				min-height: 223rpx;
				background-color: #fff;
				box-shadow: 0rpx 0rpx 11rpx rgba(0, 0, 0, 0.15);
				border-radius: 15rpx;
				margin-top: 55rpx;
			}
		}

		.logout {
			box-sizing: border-box;
			position: absolute;
			bottom: 70rpx;
			left: 0;
			width: 100%;
			padding: 0px 15rpx;
		}
	}
</style>